package main

import "fmt"

func main01() {
	defer fmt.Println("a")
	defer fmt.Println("b")
	fmt.Println("c")
}

func foo() {
	fmt.Println("hello world")
}

var value int

func foo1(a int, b int) {
	value = a + b
}

func foo2(value int) {
	fmt.Println(value)
}

func main02() {
	foo()
	//函数中有返回值,不能使用defer调用
	defer foo1(10, 20)
	foo2(value)

	fmt.Println(value)
}

func main() {
	a, b := 10, 20

	defer func(a int, b int) {
		fmt.Println("1:",a, b)
	}(a, b)

	defer func() {
		fmt.Println("2:",a, b)
	}()

	a, b = 100, 200
	fmt.Println("3:",a, b)
}
